ConfigureDc

配置分散式時鐘 (DC) 選項。分散式時鐘允許從站循環與 KINGSTAR 循環同步,強烈建議任何運動應用程式皆需避免震動。

語法

KsError ConfigureDc(
     BOOL Active,
     BOOL CheckStatus,
     BOOL MasterShift,
     int ReferenceIndex
);

參數

Active:設置 TRUE 以啟用;FALSE 停止 DC 同步,預設為 TRUE。

CheckStatus:開啟時啟用 DC 抖動檢查。同步完成後,裝置會來到運作狀態 (Op),此將會使開啟過程慢約 15 秒,預設為 TRUE。

MasterShift:選擇偏移模式,TRUE:主控裝置偏移;FALSE:總線偏移,預設為 FALSE。

Bus Shift means that the EtherCAT slaves follow the master (computer) clock. Master Shift means the slaves and the master follow one of the slaves called "Reference Clock." 依預設,參考時鐘會是總線上第一個支援 DC 的從站。

注意:從站時鐘可能會比電腦時鐘準確,因此主站偏移較為穩定,然而,主站偏移修改了電腦時鐘的速度,此將影響電腦上所有的時間戳記,若電腦上同時有其他通訊協定,此將產生問題。

ReferenceIndex:選擇參考時鐘的裝置。此參數為從站 ID,亦即裝置的 EtherCAT ID,其對應於裝置在 EtherCAT 循環中的位置 ,此 ID 從零開始,不受別名影響。

注意:尚未套用 ReferenceIndex。

回傳值

如果此函式執行成功,會回傳 errNoError,否則會傳回錯誤碼。如需更多有關錯誤碼的資訊,請參閱 KsError 清單。

備註

可用的 EtherCAT 狀態

ecatOffline

範例

複製
//////////////////////////////////////////////////////////////////
//
// This code snippet demonstrates how to use subsystem configuration
// and axis variable APIs to configure the setting before starting
// KINGSTAR subsystem.
//
//////////////////////////////////////////////////////////////////

// Variable declaration
KsError nRet = errNoError;
KsCommandStatus Command = { 0 };
SubsystemStatus Subsystem = { ecatOffline, ecatOffline, 0, 0, 0, {ecatOffline}, {ecatOffline}, {axisOffline} };
double featStatus = -1.0;

// Link to the KINGSTAR subsystem
nRet = Create(0, 0);

// Configure the subsystem settings
// Before enable the features, please check if the corresponding licenses are all enabled
// in the runtime environment.
nRet = ConfigureDc(TRUE, TRUE, TRUE, 0);
nRet = EnableAutoConfig(TRUE);
nRet = EnableAutoRepair(TRUE);
nRet = EnableAutoRestart(TRUE);
nRet = EnableHotConnect(FALSE);
nRet = EnableRedundancy(FALSE);
nRet = EnableServerLog(FALSE);
nRet = SetCycleTime(cycle500);

// Configure the axis variables
// Before enabling variables in the program, you should:
// 1. Read the user manual to check if the variables are available in the device.
// 2. Check if the corresponding variables are put in the PDO list in ESI import tool.
// For further details, see Help System >> KINGSTAR ESI Import Tool >> Tabs >> PDO.
nRet = EnableActualCurrent(TRUE);
nRet = EnableActualTorque(TRUE);
nRet = EnableActualVelocity(TRUE);
nRet = EnableAxisInput(TRUE);
nRet = EnableAxisOutput(FALSE);
nRet = EnableFollowingError(TRUE);
nRet = EnableMaxCurrent(TRUE);
nRet = EnableMaxTorque(TRUE);
nRet = EnableProfilePosition(FALSE);
nRet = EnableSecondEncoder(FALSE);
nRet = EnableSynchronizedControlMode(TRUE);
nRet = EnableTorqueOffset(FALSE);
nRet = EnableTouchProbe(FALSE);
nRet = SetAxisAccessMode(accessPos); // Refer to KsAccessMode page for detailed introduction

// Subsystem setting can be checked anytime after successfully calling Create().
// It is useful to check the feature status when you save the settings in a .kst file
// and start the subsystem via StartFromConfiguration().
nRet = GetFeatureStatus(KsFeature::featureCycleTime, &featStatus);

// Start the EtherCAT network
// You can only configure the setting before starting the subsystem
// If you need to modify the setting, call Stop() first.
Command = WaitForCommand(30, TRUE, Start());

使用需求

  RT Win32
最低支援版本 4.0 4.0
標頭檔 ksapi.h ksapi.h
程式庫 KsApi_Rtss.lib KsApi.lib

參見

Create

Start